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

.locktime_max divided by .locktime_blocks is less than 20! (can't reach 20 hops limit on mainnet) #2324

Closed
ranchalp opened this issue Feb 7, 2019 · 3 comments
Assignees
Labels

Comments

@ranchalp
Copy link

ranchalp commented Feb 7, 2019

I was having a look at the default values of c-lightning for mainnet, and noticed the following:

static const struct config mainnet_config = {
	/* ~one day to catch cheating attempts. */
	.locktime_blocks = 6 * 24,

	/* They can have up to 14 days, maximumu value that lnd will ask for by default. */
	/* FIXME Convince lnd to use more reasonable defaults... */
	.locktime_max = 14 * 24 * 6,

If I am not mistaken, if a node receives an HTLC to relay with a locktime>locktime_max it will fail by Expiry Too Far. The same will happen if a relay node to_self_delay<locktime_blocks. Therefore, the maximum amount of hops in a route that one can have with these settings are:
14, which does not comply with the 20 hops suggested by BOLT #4.

Also, this could have incompatibility issues with lnd and/or eclair, is this correct?

@cdecker cdecker added the spec label Feb 11, 2019
@cdecker
Copy link
Member

cdecker commented Feb 11, 2019

locktime_max/locktime_blocks=14, which does not comply with the 20 hops suggested by BOLT #4.

That's not really an issue. Both parameters can be chosen by the operator of the node, according to their own needs, and it would be unreasonable for us to try to allow for arbitrary lock ups. This is already holding user funds locked for 2 weeks.

Allowing 20 hops is also not a requirement by the BOLTs, but a technical parameter chosen for the onion routing packet, which is what that BOLT refers to.

Also, this could have incompatibility issues with lnd and/or eclair, is this correct?

They also enforce an upper timelock limit, pretty much like we do, by chosing a default value that is reasonable. My guess is that they also don't allow 20 days of lockups.

@cdecker cdecker self-assigned this Feb 11, 2019
@ranchalp
Copy link
Author

ranchalp commented Feb 11, 2019

Actually, had another look at it, and my bad, I think c-lightning does indeed support 20 hops. The value locktime_blocks affects cheating attemps, the value that I should have been looking at is cltv_expiry_delta:

	/* BOLT #2:
	 *
	 * 1. the `cltv_expiry_delta` for channels, `3R+2G+2S`: if in doubt, a
	 *   `cltv_expiry_delta` of 12 is reasonable (R=2, G=1, S=2)
	 */
	/* R = 2, G = 1, S = 3 */
	.cltv_expiry_delta = 14,

which is 14, so c-lightning does indeed support 20 hops. As for other implementations, lnd supports 20 hops too (their locktime_max is 5000 blocks and their cltv_expiry_delta is 144), while eclair supports up to 7 hops (locktime_max= 7 * 144 blocks and their cltv_expiry_delta is 144).

@cdecker
Copy link
Member

cdecker commented Feb 13, 2019

Thanks for checking @ranchalp

@cdecker cdecker closed this as completed Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants