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

Make cltv_expiry for keysends slightly more conservative #4548

Conversation

valentinewallace
Copy link
Contributor

Hi all! I'm working on making Rust-Lightning compatible with CL's keysend.

Would you all be open to a change like this? Rust-Lightning is a bit more conservative than the default 18 for min_final_cltv_expiry, so I thought it might be reasonable to make CL use a bit more conservative value too. Let me know what you think.

@valentinewallace valentinewallace force-pushed the raise-default-keysend-cltv-expiry branch 2 times, most recently from 3147e0e to f073422 Compare May 20, 2021 15:50
@niftynei niftynei requested a review from cdecker May 21, 2021 00:53
@cdecker cdecker self-assigned this May 24, 2021
@cdecker
Copy link
Member

cdecker commented May 25, 2021

Thanks for the proposal @valentinewallace, what's the rationale for bumping this higher? Is it just to add a bit more slack to out-of-sync nodes? And is 22 blocks somehow special?

IIRC the final CLTV delta serves two purposes:

  • Be far enough in the future to give the recipient some time to claim the incoming payment, even though the sender may be lagging slightly with its blockchain (resulting in lower absolute CLTV values, potentially causing timeouts earlier than the sender intended)
  • Be a bit of a smudging factor for the destination, allowing larger values to pretend that there are further hops. This is mostly forgotten today, and unlikely to be impacted by a constant increment of 4.

@valentinewallace
Copy link
Contributor Author

valentinewallace commented May 25, 2021

Thanks for the response @cdecker!

what's the rationale for bumping this higher? Is it just to add a bit more slack to out-of-sync nodes? And is 22 blocks somehow special?

I don't think 22 is particularly special, but yeah, I believe tl;dr the idea is to account for our peer being behind on blocks. Partly, the theory is that this may protect us from channel failures for low-power, slow peers due to HTLC expiration.

(More context: in RL, the extra fudge factor is named LATENCY_GRACE_PERIOD_BLOCKS. More docs here, i.e. we require the final CLTV delta to be greater than HTLC_FAIL_BACK_BUFFER).

@TheBlueMatt
Copy link

The final CLTV should be configurable (as it is in invoices). Lack of ability for the recipient to control their risk tolerance via the CLTV delta limit is a major shortcoming of keysend (and afaiu lnd actually requires senders to provide it). Obviously forcing it be provided from senders is a pretty terrible UX, but all the more reason to be conservative and provide a CLTV delta that a recipient is likely to support, maybe something more like the BOLT-suggested spec times two or so.

@rustyrussell
Copy link
Contributor

Yes, keysend is a hack. However, wider interoperability is always good, so changing this to 22 is the Right Thing IMHO.

@rustyrussell
Copy link
Contributor

Though I'd prefer a decent comment: it should literally be 22 with a comment saying that is the Rust lightning default and the highest we know of.

@valentinewallace valentinewallace force-pushed the raise-default-keysend-cltv-expiry branch from f073422 to ea6c902 Compare June 1, 2021 16:49
@valentinewallace valentinewallace marked this pull request as ready for review June 1, 2021 16:49
@valentinewallace
Copy link
Contributor Author

Though I'd prefer a decent comment: it should literally be 22 with a comment saying that is the Rust lightning default and the highest we know of.

Thanks Rusty, implemented this!

@niftynei niftynei added this to the v0.10.1 milestone Jun 1, 2021
@rustyrussell
Copy link
Contributor

Oh, and can we have (in the commit message) a Changelog line:

Changelog-Changed: keysend now uses 22 for the final CTLV, making it rust-lightning compatible.

(These get auto-generated into our CHANGELOG.md at release).

Thanks!

@valentinewallace valentinewallace force-pushed the raise-default-keysend-cltv-expiry branch from ea6c902 to 64385ef Compare June 7, 2021 15:51
This makes the min_cltv_expiry_delta equal to Rust-Lightning's, which is
the highest minimum we know of.

Changelog-Changed: keysend now uses 22 for the final CTLV, making it rust-lightning compatible.
@valentinewallace valentinewallace force-pushed the raise-default-keysend-cltv-expiry branch from 64385ef to 281f21b Compare June 7, 2021 15:52
@valentinewallace
Copy link
Contributor Author

Oh, and can we have (in the commit message) a Changelog line:

Changelog-Changed: keysend now uses 22 for the final CTLV, making it rust-lightning compatible.

(These get auto-generated into our CHANGELOG.md at release).

Thanks!

Sorry for the delay, done!

Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

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

Ack 281f21b

@rustyrussell rustyrussell merged commit b2ce878 into ElementsProject:master Jun 10, 2021
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.

5 participants