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

Follow-ups to #2688 #2791

Conversation

valentinewallace
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Dec 13, 2023

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (9856fb6) 88.64% compared to head (c8aa0b3) 88.65%.
Report is 89 commits behind head on main.

❗ Current head c8aa0b3 differs from pull request most recent head 3ec4d52. Consider uploading reports for the commit 3ec4d52 to get more accurate results

Files Patch % Lines
lightning/src/ln/channelmanager.rs 66.66% 4 Missing and 1 partial ⚠️
lightning/src/ln/channel.rs 88.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2791      +/-   ##
==========================================
+ Coverage   88.64%   88.65%   +0.01%     
==========================================
  Files         115      115              
  Lines       91894    91887       -7     
  Branches    91894    91887       -7     
==========================================
+ Hits        81458    81467       +9     
+ Misses       7953     7941      -12     
+ Partials     2483     2479       -4     

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

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

The follow-up changes look great!

I have one question regarding the changes and one suggestion that can further improve the PR!

Comment on lines +2552 to +2553
sha256_of_onion: self.0,
failure_code: self.1
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should revert this change.

In the reading and writing of tlvs, sha256_of_onion is followed by failure_code.

write_tlv_fields!(w, {
					(0, htlc_id, required),
					(1, failure_code, required),
					(2, dummy_err_packet, required),
					(3, sha256_of_onion, required),
				});

And if we want to prevent tuple destructing, I think we should follow tlvs order in the rest of the codebase.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think in principle I agree with you, we should have gone with (failure_code, sha256) rather than the opposite, but sadly we can't (easily) change the InboundHTLCRemovalReason serialization at this point, and IMO we should prefer to match our existing order everywhere rather than have a different order here. Its not all that critical in any direction, of course, though, we're talking about moving around 32+2 bytes.

if let ChannelError::Ignore(msg) = e {
log_trace!(logger, "Failed to fail HTLC with ID {} backwards to short_id {}: {}", htlc_id, short_chan_id, msg);
} else {
panic!("Stated return value requirements in queue_fail_{{malformed_}}htlc() were not met");
Copy link
Contributor

Choose a reason for hiding this comment

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

We are achieving a DRY code here, and that's great!

But we are also combining the panic messages that can be generated from two different sources here.
Would this be an optimal thing to do?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a good point (interpreting this as "our stack trace from the panic message won't be quite as useful as we won't be able to differentiate between the two cases"), however in this case I'm not sure we care too much about being able to differentiate, so the DRYing is likely worth more. Further, we should generally be able to differentiate the cases anyway, as logs should show different messages being received.

TheBlueMatt
TheBlueMatt previously approved these changes Jan 9, 2024
Copy link
Contributor

@vladimirfomene vladimirfomene left a comment

Choose a reason for hiding this comment

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

ACK c8aa0b3. LGTM. Just had a question and suggestion.

.map(|fail_msg_opt| fail_msg_opt.map(|_| ())))
}
};
match fail_htlc_res {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let me know what you think but I was thinking having something like the following might me more readable:

if let Some(result) = fail_htlc_res {
        match result {
            Ok(fail_msg_opt) => {
                debug_assert!(fail_msg_opt.is_some());
                update_fail_count += 1;
            },
            Err(ChannelError::Ignore(_)) => {},
            Err(e) => {
                panic!("Got a non-IgnoreError action trying to fail holding cell HTLC");
            },
        }
 }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, added a commit cleaning this up.

let res = chan.queue_fail_malformed_htlc(
htlc_id, failure_code, sha256_of_onion, &&logger
);
Some((res, htlc_id))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for storing the result of the function call in a variable res instead of putting the function call in the tuple as done on L4400?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I thought it was more readable this way since it wouldn't all fit in one line like with L4400

@TheBlueMatt TheBlueMatt merged commit db81c65 into lightningdevkit:main Jan 11, 2024
15 checks passed
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.

5 participants