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

Added possibility to configure max_concurrent_htlcs value #2858

Conversation

renepickhardt
Copy link
Collaborator

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 BOLTs max_concurrent_htlcs

Here is the relevant line in eclair:

https://github.com/ACINQ/eclair/blob/9afb26e09c69dd5d6a14732baf5dcdf2b7a9142b/eclair-core/src/main/resources/reference.conf#L62

Copy link
Collaborator

@ZmnSCPxj ZmnSCPxj left a 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.

@renepickhardt
Copy link
Collaborator Author

I added an entry to doc/lightningd however I have proplems (like last time I tried to add a manpage) to run a2x even after installing asciidoc

a2x --format=manpage doc/lightningd-config.5.txt
a2x: ERROR: "xmllint" --nonet --noout --valid "/Users/rpickhardt/hacken/tmp/lightning/doc/lightningd-config.5.xml" returned non-zero exit status 4

web search was of no help I guess I am missing some dependencies.

@rustyrussell
Copy link
Contributor

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)?

@renepickhardt
Copy link
Collaborator Author

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 min(what-peer-set, what-our-max-is) instead of max? Or did you mean what-peer-seNt (in the sense of how many did we received so far)?

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?

@renepickhardt
Copy link
Collaborator Author

renepickhardt commented Jul 30, 2019

can't I just modify this line:

> channel->config[recipient].max_accepted_htlcs) {

to test channel->config[each_side].max_accepted_htlcs

with LOCAL and REMOTE as values for each_side and take the min of both values or did I miss something in the code base?

@rustyrussell
Copy link
Contributor

can't I just modify this line:

> channel->config[recipient].max_accepted_htlcs) {

to test channel->config[each_side].max_accepted_htlcs

with LOCAL and REMOTE as values for each_side and take the min of both values or did I miss something in the code base?

Yes, exactly, that would have the same effect.

@rustyrussell rustyrussell added this to the 0.7.2 milestone Aug 6, 2019
@renepickhardt renepickhardt force-pushed the max_concurrent_htlc_configurable branch from f775593 to e564b0c Compare August 7, 2019 13:59
@renepickhardt
Copy link
Collaborator Author

I added the additional patch as @rustyrussell requested and rebased to current master. Think everything should be working now. fyi @cdecker

@rustyrussell
Copy link
Contributor

I added an entry to doc/lightningd however I have proplems (like last time I tried to add a manpage) to run a2x even after installing asciidoc

a2x --format=manpage doc/lightningd-config.5.txt
a2x: ERROR: "xmllint" --nonet --noout --valid "/Users/rpickhardt/hacken/tmp/lightning/doc/lightningd-config.5.xml" returned non-zero exit status 4

web search was of no help I guess I am missing some dependencies.

I got this too recently. But Works Now, so I'm adding a simple fixup.

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.

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.

@@ -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).
Copy link
Contributor

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.

@@ -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)");
Copy link
Contributor

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.

@rustyrussell rustyrussell dismissed ZmnSCPxj’s stale review August 8, 2019 02:03

30 is a reasonable upper bound to avoid bloating atttacks.

@rustyrussell
Copy link
Contributor

check-source got upset because it thought your comment was part of the BOLT quote. Split.

@renepickhardt
Copy link
Collaborator Author

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!

Copy link
Collaborator Author

@renepickhardt renepickhardt left a 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

@renepickhardt renepickhardt force-pushed the max_concurrent_htlc_configurable branch from c4b4f9b to d959421 Compare August 8, 2019 07:57
@practicalswift
Copy link
Contributor

Nit: Typo in PR title and commit message. Should be "possibility" :-)

@renepickhardt
Copy link
Collaborator Author

am I supposed to change the commit message now?

@ZmnSCPxj
Copy link
Collaborator

ZmnSCPxj commented Aug 8, 2019

Yes. :)

@renepickhardt renepickhardt force-pushed the max_concurrent_htlc_configurable branch from d959421 to 697c86c Compare August 8, 2019 14:24
@renepickhardt
Copy link
Collaborator Author

@ZmnSCPxj @practicalswift I can't believe I actually did that (and while so I also fixed configer to configure)

@renepickhardt renepickhardt changed the title Added possability to configure max_concurrent_htlcs value Added possibility to configure max_concurrent_htlcs value Aug 8, 2019
@rustyrussell rustyrussell force-pushed the max_concurrent_htlc_configurable branch 2 times, most recently from 47b73c8 to b657581 Compare August 9, 2019 02:29
@rustyrussell
Copy link
Contributor

rustyrussell commented Aug 9, 2019

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.
@rustyrussell rustyrussell force-pushed the max_concurrent_htlc_configurable branch from b657581 to e524093 Compare August 9, 2019 03:55
@rustyrussell
Copy link
Contributor

rustyrussell commented Aug 9, 2019

... and again to fix merge conflict with master...

Ack e524093

@rustyrussell rustyrussell merged commit dfac1d1 into ElementsProject:master Aug 9, 2019
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;
Copy link

@SomberNight SomberNight Mar 27, 2020

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)

Copy link

@SomberNight SomberNight Mar 27, 2020

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.

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

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants