-
Notifications
You must be signed in to change notification settings - Fork 905
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
Added possibility to configure max_concurrent_htlcs value #2858
Added possibility to configure max_concurrent_htlcs value #2858
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs documentation:
diff of command names vs manpage names: --- /dev/fd/63 2019-07-28 07:26:31.096200068 +0000 +++ /dev/fd/62 2019-07-28 07:26:31.096200068 +0000 @@ -35,7 +35,6 @@ log-level= log-prefix= mainnet -max-concurrent-htlcs= max-locktime-blocks= min-capacity-sat= network= doc/Makefile:80: recipe for target 'check-manpages' failed
I mildly prefer 483, as we expect (hope?) unilateral closure to be rare.
I added an entry to
web search was of no help I guess I am missing some dependencies. |
This doesn't solve your problem though, as this doesn't restrict how many HTLCs we'll send to a peer, just how many we'll receive. I would suggest a follow-up patch which caps the sending number to max(what-peer-set, what-our-max-is)? |
While the first paragraph of your review makes sense to me I am confused by your suggestion for a follow up patch. Shouldn't it be In my understanding concurrent htlcs was meant to be offered plus received. So the max would not help here as we would have to check against the current sum in both cases or is there a mistake in my thinking? |
can't I just modify this line: lightning/channeld/full_channel.c Line 451 in 54ce4ed
to test with |
Yes, exactly, that would have the same effect. |
f775593
to
e564b0c
Compare
I added the additional patch as @rustyrussell requested and rebased to current master. Think everything should be working now. fyi @cdecker |
I got this too recently. But Works Now, so I'm adding a simple fixup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some fixups for your review @renepickhardt because we're 2 days from rc1 and I'm trying to minimize round-trips across timezones!
If you're happy, either you or I can autosquash them for commit.
doc/lightningd-config.5.txt
Outdated
@@ -205,6 +205,10 @@ Lightning channel and HTLC options | |||
they're outside this range, we abort their opening attempt. Note | |||
that *commit-fee-max* can (should!) be greater than 100. | |||
|
|||
*max-concurrent-htlcs*='INTEGER':: | |||
Number of HTLCs one channel can handle concurrently. Should be between | |||
1 and 483 (default 30). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in each direction. The max possible total will be twice this number. Will add.
lightningd/options.c
Outdated
@@ -928,6 +939,9 @@ static void register_opts(struct lightningd *ld) | |||
opt_register_arg("--fee-per-satoshi", opt_set_u32, opt_show_u32, | |||
&ld->config.fee_per_satoshi, | |||
"Microsatoshi fee for every satoshi in HTLC"); | |||
opt_register_arg("--max-concurrent-htlcs", opt_set_u32, opt_show_u32, | |||
&ld->config.max_concurrent_htlcs, | |||
"Number of HTLCs one channel can handle concurrently. Should be between 1 and 483 (default 30)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't quite work:
--max-concurrent-htlcs <arg> Number of HTLCs one channel can handle
concurrently. Should be between 1 and
483 (default 30) (default: 0)
because you included a show function, it's used to show the default automagically. However, you only set it in the mainnet config, so it's zero (a very bad number!) for other configs.
30 is a reasonable upper bound to avoid bloating atttacks.
check-source got upset because it thought your comment was part of the BOLT quote. Split. |
I can autosquash that patch to be one commit in about 1 hour and rebase again if necessary so that it is ready to be merged. I did not know you test for bolt quotes. That is beautiful! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this all together looks good to me. will autosquash and rebase once more
c4b4f9b
to
d959421
Compare
Nit: Typo in PR title and commit message. Should be "possibility" :-) |
am I supposed to change the commit message now? |
Yes. :) |
d959421
to
697c86c
Compare
@ZmnSCPxj @practicalswift I can't believe I actually did that (and while so I also fixed configer to configure) |
47b73c8
to
b657581
Compare
Ack b657581 Rebased to squash fixup and fixed your commit msg |
…nnels. Eclaire has a default of 30 and I thought why not going with their value and while doing so make it configureable.
… both peers of a channel
b657581
to
e524093
Compare
... and again to fix merge conflict with master... Ack e524093 |
if (tal_count(committed) - tal_count(removing) + tal_count(adding) | ||
> channel->config[recipient].max_accepted_htlcs) { | ||
> min_concurrent_htlcs) { | ||
return CHANNEL_ERR_TOO_MANY_HTLCS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me that the spec specifies only counting htlc in one direction (not both) against this limit, further it only specifies comparing against the recipient's constraint.
Obviously you can enforce arbitrary restrictions (stricter than spec) for outgoing HTLCs, but if you enforce stricter restrictions than the spec says for incoming ones and then you force-close when (not if) they are violated by the remote then that's not ideal?
See what eclair does (as above) here:
https://github.com/ACINQ/eclair/blob/eae113f0988069044dc268d8a7f16728563baa5f/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala#L216
https://github.com/ACINQ/eclair/blob/eae113f0988069044dc268d8a7f16728563baa5f/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala#L259
(check only one direction of HTLCs against only one of the constraints)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I've just realised that the channel does not actually get force-closed, only the peer gets disconnected from (and then the htlc is not added as it was not committed).
BOLT-02 specifically says "fail the channel" - I guess I had a different interpretation of that...
I mean BOLT-02 sometimes says "fail the connection" and sometimes "fail the channel", but then that means c-lightning considers those both to be identical?
Re the original remark, I guess it's less bad then, but still not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: my comments have been addressed in #4432 which reverted the strict checks for remote behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, only one of the two concerns have been addressed by #4432.
AFAICT c-lightning is still checking the total number of htlcs (sum of both directions) against max_accepted_htlcs
, while I think BOLT-02 only specifies to check the number of htlcs the sender offered (so one direction only).
This is means c-lightning is still stricter than e.g. eclair.
lightning/channeld/full_channel.c
Lines 575 to 578 in 9470ea3
if (tal_count(committed) - tal_count(removing) + tal_count(adding) | |
> channel->config[recipient].max_accepted_htlcs) { | |
return CHANNEL_ERR_TOO_MANY_HTLCS; | |
} |
Or am I misunderstanding the code here? It seems to me
committed
, removing
, and adding
include htlcs in both directions.@rustyrussell
Eclair has a default value of 30 and I thought why not going with their value and while doing so make it configureable.
@cdecker suggested to call the option
max_concurrent_htlcs
instead of the name in the BOLTsmax_concurrent_htlcs
Here is the relevant line in eclair:
https://github.com/ACINQ/eclair/blob/9afb26e09c69dd5d6a14732baf5dcdf2b7a9142b/eclair-core/src/main/resources/reference.conf#L62