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

Stop sending channel_update in onion failures #3345

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tankyleo
Copy link

@tankyleo tankyleo commented Oct 1, 2024

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 86.88525% with 8 lines in your changes missing coverage. Please review.

Project coverage is 89.55%. Comparing base (c7627df) to head (9e30f25).
Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 82.97% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3345      +/-   ##
==========================================
- Coverage   89.67%   89.55%   -0.12%     
==========================================
  Files         126      127       +1     
  Lines      103165   103469     +304     
  Branches   103165   103469     +304     
==========================================
+ Hits        92510    92660     +150     
- Misses       7935     8104     +169     
+ Partials     2720     2705      -15     
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@dunxen dunxen left a comment

Choose a reason for hiding this comment

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

Thanks! Just skimmed the diff for now and will give it a proper look later.

Don't worry about the failing mutants CI job as the diff is triggering a bunch of existing missed mutants.

lightning/src/ln/channelmanager.rs Show resolved Hide resolved
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

I was reviewing this code during the Tokyo summit last week. Since you've already done the work, I added a couple of comments. Some might be unnecessary, and others are just to help me understand your changes 😄

lightning/src/ln/channelmanager.rs Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Show resolved Hide resolved
Comment on lines +5602 to +5605
let failure_code = 0x1000|7;
let data = self.get_htlc_inbound_temp_fail_data(failure_code);
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO there was no reason to change the function return type, is it?

Copy link
Author

@tankyleo tankyleo Oct 2, 2024

Choose a reason for hiding this comment

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

In case this function failed to fetch the channel_update, it previously indicated this to the caller by returning an 0x4000 error, and the caller would reassign the 0x1000 code with the 0x4000 code.

In case the channel_update fetch was successful, the returned error code was the same as the one passed in.

This function no longer has this potential fetch failure, so it will never reassign the error code value to a different value. So we don't need to return an error code value any longer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I noted it, and make sense of your explaination. Probably just bias because the previous function was more "elegant" from the code point of view. Thanks for explaination

Comment on lines +6448 to +6453
let failure_code = 0x1000|7;
let data = self.get_htlc_inbound_temp_fail_data(failure_code);
Copy link
Contributor

Choose a reason for hiding this comment

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

👁️

lightning/src/ln/onion_route_tests.rs Show resolved Hide resolved
@tankyleo
Copy link
Author

tankyleo commented Oct 2, 2024

I was reviewing this code during the Tokyo summit last week. Since you've already done the work, I added a couple of comments. Some might be unnecessary, and others are just to help me understand your changes 😄

Sorry I should have understood better, thank you for the review !

// See https://github.com/lightning/bolts/blob/341ec84/04-onion-routing.md?plain=1#L1008
0u16.write(&mut enc).expect("Writes cannot fail");
}
(0u16).write(&mut enc).expect("Writes cannot fail");
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it seems kind of obvious for no channel update, but could we perhaps link to https://github.com/lightning/bolts/blob/247e83d528a2a380e533e89f31918d7b0ce6a0c1/04-onion-routing.md?plain=1#L1414-L1415 in a comment?

Sorry for only seeing this now!

Copy link
Author

Choose a reason for hiding this comment

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

No problem you are right, I think it's worth adding this reference.

Copy link
Author

Choose a reason for hiding this comment

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

Please see below, I added the link in the two places where it is relevant.

I only included the first 7 characters of the commit hash, partly to keep it consistent with the link further above in the location you pointed out.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Damn, I was hoping this would get us some nice lock cleanups, but oh well, its still fixing some bugs in phantom and removing code.

let mut fail_conditions = PaymentFailedConditions::new()
.blamed_scid(phantom_scid)
.expected_htlc_error_data(0x2000 | 2, &[]);
.expected_htlc_error_data(0x1000 | 13, &err_data);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!

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