Skip to content

Fix holding cell freeing in case we fail to add some HTLC #295

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

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

Based on #294.

Previously, if we went to free the holding cell HTLC updates, and
adding one failed as we hit our outbound HTLC limit (or in-flight
value limit), we would not send a commitment_signed, leaving us in
an invalid state. We first fix that bug, and then refuse to add
things to our holding cell once we reach our limits considering the
holding cell, as we shouldn't have multiple commitment dance rounds
worth of HTLCs in the holding cell anyway.

@TheBlueMatt TheBlueMatt force-pushed the 2019-01-holding-cell-limits branch 2 times, most recently from 0616f46 to 81142ac Compare January 21, 2019 19:20
@TheBlueMatt TheBlueMatt added this to the 0.0.8 milestone Jan 21, 2019
@TheBlueMatt TheBlueMatt force-pushed the 2019-01-holding-cell-limits branch 2 times, most recently from b377d06 to d0275f8 Compare January 22, 2019 19:33
@TheBlueMatt
Copy link
Collaborator Author

Rebased.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

See comments about your assumption if we hit HTLCs limit.
Btw, on d0275f8, channel.rs L 3171, in send_htlc, seems that comment doesn't match with check (think that is the comment which is wrong). Same on below check.

@@ -1863,6 +1872,11 @@ impl Channel {
}
if err.is_some() {
self.holding_cell_htlc_updates.push(htlc_update);
if let Some(ChannelError::Ignore(_)) = err {
Copy link

Choose a reason for hiding this comment

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

Your test don't check that right ? Because commenting out this part, it's still a success. So new requirement "if we went to free the holding cell HTLC updates, and adding one failed as we hit our outbound HTLC limit (or in-flight value limit), we would not send a commitment_signed" is not covered by test ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, its not covered by the test, I'm not actually sure how to hit it after the other fixes, but if you dont have it and you do get a failure you will see the chanmon_fail_consistency test fail due to broken consistency (also if you only include this fix and comment out the "Cannot push more than their max accepted HTLCs" check, the test fails).

Copy link

Choose a reason for hiding this comment

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

Yes try to hit it but seems hard to me because you will ever hit fix in get_outbound_pending_htlc_states while waiting for remote RAA and at handling this one you will flush the whole in a strait. You weren't able to backport the failure from chanmon_fail_consistency ? (try to test but hit failure assert from rust-secp on 1.29.2). Wonder if the fail come from an AddHTLC and not other cases..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The test case here is (essentially) the backport from the fuzz test, but it won't actually hit because of the changes to considering holding cell when adding. Note that if you comment those changes out and a few bits of the test you can test this.

Copy link

Choose a reason for hiding this comment

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

Yes but because fix in get_outbound_pending_htlc_stats, are we sure that the one in free_holding_cell_htlcs is still relevant? As you said you don't know how to hit it and me too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I'm not, but it cant hurt :p (and I know its possible to hit with update_fee stuff, but hopefully that goes away before we have to care).

Copy link

Choose a reason for hiding this comment

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

Ahah okay agree on the can't hurt

@TheBlueMatt TheBlueMatt force-pushed the 2019-01-holding-cell-limits branch from d0275f8 to 9e31403 Compare January 24, 2019 16:42
@ariard
Copy link

ariard commented Jan 25, 2019

Also see #295 (review), seems to me some errors msgs in send_htlc are wrong.

@ariard
Copy link

ariard commented Jan 25, 2019

Oh and maybe confusing "And then refuse to add things to our holding cell once we reach our limits considering the holding cell" isn't this TODO L3186 in channel.rs ?

@TheBlueMatt
Copy link
Collaborator Author

As for the error messages being confused, who's reserve value things are kinda goes both ways. Its our reserve value in that its the amount we have to keep to ourselves (as reserve), but its set by them, and to keep variable names consistent, the variable is their_reserve.

@ariard
Copy link

ariard commented Jan 25, 2019

Nah don't talking about reserve value, but the one above, we check against their_max_htlc_value_in_flight_msat but we send back as error msg "Cannot send value that would put us over our max HTLC value in flight"?

@TheBlueMatt TheBlueMatt force-pushed the 2019-01-holding-cell-limits branch from 9e31403 to 1fa1545 Compare January 25, 2019 02:28
@TheBlueMatt
Copy link
Collaborator Author

After IRC discussion removed the "our" to reduce confusion.

@TheBlueMatt TheBlueMatt force-pushed the 2019-01-holding-cell-limits branch 4 times, most recently from 1a718e5 to 0b76979 Compare January 25, 2019 02:53
Previously, if we went to free the holding cell HTLC updates, and
adding one failed as we hit our outbound HTLC limit (or in-flight
value limit), we would not send a commitment_signed, leaving us in
an invalid state. We first fix that bug, and then refuse to add
things to our holding cell once we reach our limits considering the
holding cell, as we shouldn't have multiple commitment dance rounds
worth of HTLCs in the holding cell anyway.
@TheBlueMatt TheBlueMatt force-pushed the 2019-01-holding-cell-limits branch from 0b76979 to bf26056 Compare January 25, 2019 02:53
@TheBlueMatt TheBlueMatt merged commit 3117e18 into lightningdevkit:master Jan 25, 2019
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.

2 participants